package com.glm.fruit.service;

import com.glm.fruit.entity.CartItem;

import java.util.List;

public class StrawberryDiscountPromotion implements Promotion{
    public double apply(List<CartItem> items, double total) {
        double discount = 0;
        for (CartItem item : items) {
            if ("草莓".equals(item.getFruit().getName())) {
                discount += item.getSubtotal() * 0.2;
            }
        }
        return total - discount;
    }

}
